package com.personnelsystem;

import java.util.Arrays;
import java.util.List;
import java.util.Scanner;

public class test {
    public static void main(String[] args) {

        Scanner scanner = new Scanner(System.in);

        java.lang.String s1 = scanner.nextLine();

        java.lang.String s2=scanner.next();

        int d1[]=new int[2];

        change(s1,d1);
        int a=d1[0];
        int b=d1[1];

        change(s2,d1);
        int c=d1[0];
        int d=d1[1];

        //对结果进行处理

        int e=a*c-b*d;
        int f=b*c+a*d;

        StringBuffer re=new StringBuffer();
        re.append(e);
        if(f<0)
            re.append(f);
        else {
            re.append("+");
            re.append(f);
        }

        re.append("i");
        System.out.println(re.toString());
    }


    //
    public static void change(String s,int d[]){
        char temp[] = s.toCharArray();
        char op1 = '-';
        StringBuffer s1 = new StringBuffer();
        int i;
        for (i = 0; i < temp.length; i++) {

            if (temp[i] == '-' || temp[i] == '+') {
                op1 = temp[i];
                break;
            }
            s1.append(temp[i]);

        }


        int a = Integer.valueOf(s1.toString());
        d[0]=a;

        //注意为啥不用string去拷贝字符数组
        StringBuffer st = new StringBuffer();
        for (int j = i+1; j < temp.length; j++)
            if (temp[j] != 'i')
                st.append(temp[j]);

        int b = Integer.valueOf(st.toString());
        if(op1=='-')
            b=-b;

        d[1]=b;

    }
}
